<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="csrf-token" content="{{ csrf_token }}">
    <title>{% block title %}多用户报警系统{% endblock %}</title>
    {% load static %}
    <!-- Bootstrap CSS -->
    <link href="{% static 'bootstrap/css/bootstrap.min.css' %}" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="{% static 'font-awesome/css/font-awesome.min.css' %}" rel="stylesheet">
    <!-- Webhooks页面样式 -->
    <link href="{% static 'css/webhooks.css' %}" rel="stylesheet">
    <!-- Webhooks样式修复 -->
    <link href="{% static 'css/webhooks_fix.css' %}" rel="stylesheet">
    <!-- Webhooks列表样式修复 -->
    <link href="{% static 'css/webhooks_list_fix.css' %}" rel="stylesheet">
    <!-- Badge颜色对比度修复 -->
    <link href="{% static 'css/badge_contrast_fix.css' %}" rel="stylesheet">
    <!-- 自定义CSS -->
    <style>
        /* 基础样式 */
        body {
            background-color: #f8f9fa;
            color: #212529;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
        }
        
        /* 导航栏样式 */
        .navbar {
            background-color: #ffffff;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }
        
        .navbar-brand {
            font-weight: bold;
            color: #1677ff;
            font-size: 1.25rem;
        }
        
        .navbar-brand:hover {
            color: #0958d9;
        }
        
        .nav-link {
            color: #212529;
            transition: color 0.2s;
        }
        
        .nav-link:hover {
            color: #1677ff;
        }
        
        /* 主容器样式 */
        .main-container {
            min-height: calc(100vh - 100px);
            padding-top: 20px;
            padding-bottom: 20px;
        }
        
        /* 卡片样式 */
        .card {
            border: none;
            border-radius: 8px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
            transition: transform 0.2s, box-shadow 0.2s;
        }
        
        .card:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
        }
        
        .card-header {
            background-color: #ffffff;
            border-bottom: 1px solid #f0f0f0;
            font-weight: bold;
            color: #212529;
        }
        
        /* 按钮样式 */
        .btn {
            border-radius: 6px;
            font-weight: 500;
            transition: all 0.2s;
        }
        
        .btn-primary {
            background-color: #1677ff;
            border-color: #1677ff;
        }
        
        .btn-primary:hover {
            background-color: #0958d9;
            border-color: #0958d9;
        }
        
        .btn-success {
            background-color: #52c41a;
            border-color: #52c41a;
        }
        
        .btn-success:hover {
            background-color: #389e0d;
            border-color: #389e0d;
        }
        
        .btn-danger {
            background-color: #f5222d;
            border-color: #f5222d;
        }
        
        .btn-danger:hover {
            background-color: #cf1322;
            border-color: #cf1322;
        }
        
        .btn-warning {
            background-color: #faad14;
            border-color: #faad14;
        }
        
        .btn-warning:hover {
            background-color: #d48806;
            border-color: #d48806;
        }
        
        .btn-info {
            background-color: #13c2c2;
            border-color: #13c2c2;
        }
        
        .btn-info:hover {
            background-color: #08979c;
            border-color: #08979c;
        }
        
        /* 表单样式 */
        .form-control {
            border-radius: 6px;
            border: 1px solid #d9d9d9;
            transition: border-color 0.2s, box-shadow 0.2s;
        }
        
        .form-control:focus {
            border-color: #1677ff;
            box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.2);
        }
        
        /* 表格样式 */
        .table {
            border-collapse: separate;
            border-spacing: 0;
            border-radius: 8px;
            overflow: hidden;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        }
        
        .table th,
        .table td {
            padding: 12px 16px;
            vertical-align: middle;
            border-color: #f0f0f0;
        }
        
        .table thead th {
            background-color: #fafafa;
            font-weight: 600;
            color: #212529;
            border-bottom: 2px solid #f0f0f0;
            font-size: 0.875rem;
            text-transform: uppercase;
            letter-spacing: 0.025em;
        }
        
        .table tbody tr {
            transition: background-color 0.2s, box-shadow 0.2s;
        }
        
        .table tbody tr:hover {
            background-color: #fafafa;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        }
        
        /* 长文本自动换行样式 */
        .break-all {
            word-break: break-all;
            white-space: normal;
            word-wrap: break-word;
        }
        
        .text-truncate-2 {
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
            line-height: 1.4;
        }
        
        /* 表格单元格样式优化 */
        .td-content {
            max-width: 400px;
            word-wrap: break-word;
            line-height: 1.5;
        }
        
        .td-tags {
            min-width: 120px;
        }
        
        .td-status {
            min-width: 80px;
            text-align: center;
        }
        
        .td-actions {
            min-width: 100px;
            white-space: nowrap;
        }
        
        /* 标签样式 */
        .tag {
            display: inline-block;
            padding: 4px 8px;
            border-radius: 4px;
            font-size: 0.75rem;
            font-weight: 500;
            color: white;
            transition: transform 0.2s, box-shadow 0.2s;
        }
        
        .tag:hover {
            transform: translateY(-1px);
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
        }
        
        /* 角色徽章样式 */
        .role-badge {
            padding: 4px 8px;
            border-radius: 4px;
            font-size: 0.75rem;
            font-weight: 500;
        }
        
        .role-admin {
            background-color: #1677ff;
            color: white;
        }
        
        /* 卡片悬停效果 */
        .hover-lift {
            transition: transform 0.2s ease, box-shadow 0.2s ease;
        }
        
        .hover-lift:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
        }
        
        /* 按钮悬停动画 */
        .btn-hover-animate {
            transition: all 0.3s ease;
            position: relative;
            overflow: hidden;
        }
        
        .btn-hover-animate:hover {
            transform: translateY(-1px);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        }
        
        /* 图标对齐 */
        .icon-align {
            vertical-align: middle;
            margin-right: 4px;
        }
        
        .role-editor {
            background-color: #52c41a;
            color: white;
        }
        
        .role-viewer {
            background-color: #faad14;
            color: white;
        }
        
        /* 消息提示样式 */
        .alert {
            border-radius: 6px;
            border: none;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        }
        
        /* 图标按钮样式 */
        .btn-icon {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 32px;
            height: 32px;
            padding: 0;
            border-radius: 50%;
            margin-right: 8px;
        }
        
        /* 页脚样式 */
        footer {
            background-color: #ffffff;
            color: #6c757d;
            padding: 20px 0;
            border-top: 1px solid #f0f0f0;
            margin-top: 40px;
        }
    </style>
</head>
<body>
    <!-- 导航栏 -->
    <nav class="navbar navbar-expand-lg sticky-top">
        <div class="container-fluid">
            <a class="navbar-brand" href="/">
                <i class="fa fa-bell-o" aria-hidden="true"></i> 多用户报警系统
            </a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                {% if user.is_authenticated %}
                    <ul class="navbar-nav me-auto">
                        <li class="nav-item">
                            <a class="nav-link" href="{% url 'projects:dashboard' %}">
                                <i class="fa fa-home" aria-hidden="true"></i> 首页
                            </a>
                        </li>
                        {% if user.is_super_admin %}
                        <li class="nav-item">
                            <a class="nav-link" href="{% url 'accounts:user_list' %}">
                                <i class="fa fa-users" aria-hidden="true"></i> 用户管理
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{% url 'projects:announcement_create' %}">
                                <i class="fa fa-bullhorn" aria-hidden="true"></i> 发送公告
                            </a>
                        </li>
                        {% endif %}
                    </ul>
                    <ul class="navbar-nav">
                        <li class="nav-item dropdown">
                            <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                                <i class="fa fa-user-circle-o" aria-hidden="true"></i> {{ user.username }}
                            </a>
                            <ul class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdown">
                                <!-- dashboard路径已隐藏 -->
                                <li><hr class="dropdown-divider"></li>
                                <li><a class="dropdown-item" href="{% url 'accounts:logout' %}"><i class="fa fa-sign-out" aria-hidden="true"></i> 退出登录</a></li>
                            </ul>
                        </li>
                    </ul>
                {% else %}
                    <ul class="navbar-nav ms-auto">
                        <li class="nav-item">
                            <a class="nav-link" href="{% url 'accounts:login' %}">
                                <i class="fa fa-sign-in" aria-hidden="true"></i> 登录
                            </a>
                        </li>
                    </ul>
                {% endif %}
            </div>
        </div>
    </nav>

    <!-- 主内容区域 -->
    <div class="container main-container">
        <!-- 消息提示 -->
        {% if messages %}
            {% for message in messages %}
                <div class="alert alert-{{ message.tags }} alert-dismissible fade show" role="alert">
                    <i class="fa fa-info-circle" aria-hidden="true"></i> {{ message }}
                    <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
                </div>
            {% endfor %}
        {% endif %}
        
        <!-- 页面内容 -->
        {% block content %}
        {% endblock %}
    </div>

    <!-- 页脚 -->
    <footer>
        <div class="container text-center">
            <p>&copy; {% now 'Y' %} 多用户报警系统 | 技术支持：Python + Django</p>
        </div>
    </footer>

    <!-- Bootstrap JS -->
    <script src="{% static 'bootstrap/js/bootstrap.bundle.min.js' %}"></script>
    <!-- 自定义JS -->
    {% block javascript %}
    {% endblock %}
</body>
</html>